﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using ChannelVN.CMS.Common;
using ChannelVN.CMS.DynamicLayout.FrontEnd.Common;

namespace ChannelVN.CMS.DynamicLayout.FrontEnd.Dal
{
    public class NewsConfigDal
    {
        public static string GetByConfigName(string configName)
        {
            SqlDataReader reader = null;

            try
            {
                var parameters = new[]
                                     {                                         
                                         new SqlParameter("@ConfigName", configName),                                       
                                     };
                reader = SqlHelper.ExecuteReader(ConfigValues.FrontEndConnectionString,
                                                    CommandType.StoredProcedure,
                                                    "CMS_NewsConfig_GetByConfigName", parameters);

                if (reader.Read() && null != reader["ConfigValue"])
                    return reader["ConfigValue"].ToString();
                else
                    return string.Empty;
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("CMS_NewsConfig_GetByConfigName:{0}", ex.Message));
            }
            finally
            {
                if (null != reader && !reader.IsClosed) reader.Close();
            }
        }
    }
}
